import { defineStore } from "pinia";
import {getMyUserInfo} from '@/api/user'

const useUserInfo = defineStore('userInfo', {
    state: () => {
        return {
            avatar: '',
            sex: 0,
            sign: '',
            name: '',
        }
    },
    actions: {
        setUserInfo(data) {
            this.avatar = data.avatar
            this.sex = data.sex
            this.sign = data.sign
            this.name = data.name
        },
        async getUserInfo(){
            let data=(await getMyUserInfo()).data
            this.avatar=data.avatar
            this.sex=data.sex
            this.sign=data.sign
            this.name=data.name
        }
    }
})

export default useUserInfo